import request from "@u/request";

//首页轮播图
const fetchHomeBanner = (params = {}) => {
    return request.get('/banner/list', { params })
  }

//商品分类列表 /shop/goods/category/all
const fetchCates = (params = {}) => {
    return request.get('/shop/goods/category/all', {params})
}

//商品列表请求  /shop/goods/list/v2   获取指定分类的商品
const fetchItems = (params = {}) => {
  return request.post('/shop/goods/list/v2', params)
}
//商品详情请求 /shop/goods/detail
const fetchItemDetail = (params = {}) => {
  return request.get('/shop/goods/detail', {params})
}
// 用户注册
const userReg = (params = {}) => (
  request.post('/user/username/register', params)
)
// 用户登录
const userLogin = (params = {}) => (
  request.post('/user/username/login', params)
)
//加入购物车 /shopping-cart/add  post
const addItemToCart = (params = {}) => (
  request.post('/shopping-cart/add', params)
)
//读取购物车数据  /shopping-cart/info   get
const ReadShoppingCart = (params = {}) => {
  return request.get('/shopping-cart/info', {params})
}
//购物车修改商品数量  /shopping-cart/modifyNumber  key  number
  export {
    fetchHomeBanner,
    fetchCates,
    fetchItems,
    fetchItemDetail,
    userReg,
    userLogin,
    addItemToCart,
    ReadShoppingCart
  }